<template>
   <div>
      <home-header ></home-header>
      <home-swiper :list="swiperList"></home-swiper>
      <home-icon :list="icons"></home-icon>
      <home-recommend :list="recommendList"></home-recommend>
      <home-weekend :list="weekendlist"></home-weekend>
   </div>
</template>
<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcon from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
    name:'Home',
    components:{
       HomeHeader,
       HomeSwiper,
       HomeIcon,
       HomeRecommend,
       HomeWeekend
    },
    data(){
       return {
          swiperList:[],
          icons:[],
          recommendList:[],
          weekendlist:[]
       }
    },
    methods:{
       getHomeInfoSucc(res){    
          this.swiperList=res.data.data.swiperList
          this.icons=res.data.data.iconList
          this.recommendList=res.data.data.recommendList
            this.weekendlist=res.data.data.weekendList
       },
       getHomeInfo(){
 // 为给定 ID 的 user 创建请求
axios.get('/api/index.json')
  .then(this.getHomeInfoSucc)
  .catch(function (error) {
    console.log(error);
  });
       }
    },
    mounted:function(){
     this.getHomeInfo()  
    }
}
</script>
<style>

</style>

